package com.example.online_order.mapper;

import com.example.online_order.pojo.Evalate;
import com.example.online_order.pojo.Orders;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface EvalateMapper {
    //    查询（全表查询  按用户名查询 按菜品名称查询 模糊查询） 删除，新增 修改（追评不修改原来的只追加）

    @Select("select * from evalate")
    public List<Evalate> getAllEva();

    @Select("select * from evalate where id=#{id}")
    public Evalate getById(Integer id);

    @Select("select * from evalate where userName =#{userName}")
    public List<Evalate> getByUserName(String userName);

    @Select("select * from evalate where userId =#{userId}")
    public List<Evalate> getByUserId(Integer userId);

    @Select("select * from evalate where mealId =#{mealId}")
    public List<Evalate> getByMealId(Integer mealId);

    @Select("select * from evalate where mealName =#{mealName}")
    public List<Evalate> getByMealName(String mealName);

    @Select("select * from evalate where mealLevel =#{mealLevel}")
    public List<Evalate> getByMealLevel(Integer mealLevel);

    @Select("select * from evalate where userName like '%${userName}%' or mealName like '%${mealName}%'")
    public List<Evalate> selectevaLikeUserMeal(String userName, String mealName);

    @Insert("insert into evalate values (null, #{mealLevel}, #{description}, #{userId}, #{userName}, #{evaTime}, #{mealId}, #{mealName})")
    public Integer addEva(Evalate evalate);

    @Delete("delete from evalate where id =#{id}")
    public Integer deleteEva(Integer id);

    @Update("update evalate set" +
            " mealLevel= #{mealLevel}," +
            "description = #{description}," +
            " userId= #{userId}, " +
            "userName= #{userName}, " +
            "evaTime= #{evaTime}, " +
            "mealId= #{mealId}, " +
            "mealName= #{mealName} where id= #{id}")
    public Integer updateEva(Evalate evalate);


}
